﻿
<!--header-e-->
<div class="search-box p">
    <div class="w1224">
        <div class="search-path fl">
            <p style="float: left;">当前位置：</p>
            <a href="/packet">数据包集市</a>
            <i class="litt-xyb"></i>
            <a href="/packet-1">政务生态圈</a>
            <i class="litt-xyb"></i>
            <a href="/packet-11">智慧城市</a>
            <i class="litt-xyb"></i>
            <a href="/packet-48">智慧交通</a>
            <i class="litt-xyb"></i>
        </div>
    </div>
</div>
<div class="details-bigimg p">
    <div class="w1224">
        <div class="detail-img">
            <div class="product-gallery">
                <!-- 商品图片介绍 start -->
                <div class="product-img">
                    <img id="zoomimg" src="<?=base_url()?>picture/<?php echo $data['pic_url']?>">
                </div>
                <!-- 商品图片介绍 end -->
                <ul>
                    <li class="fl use">
                        <span class="collect-text"><span id="userSum"><?php echo $data['number']?></span>使用</span>
                    </li>
                    <li class="fr collect">
                        <a href="javascript:void(0);" id="collectLink">
                            <span class="collect-ico"></span>
                            <span class="collect-text"><span id="collectSum">0</span>收藏</span>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <form id="buy_goods_form" name="buy_goods_form" method="post" action="/Home-Virtual-buy_virtual.html">
            <input type="hidden" name="goods_id" value="8"><!-- 商品id -->
            <input type="hidden" name="goods_prom_type" value="0"/><!-- 活动类型 -->
            <input type="hidden" name="shop_price" value="18.00"/><!-- 活动价格 -->
            <input type="hidden" name="store_count" value="10002"/><!-- 活动库存 -->
            <input type="hidden" name="market_price" value="38.00"/><!-- 商品原价 -->
            <input type="hidden" name="start_time" value=""/><!-- 活动开始时间 -->
            <input type="hidden" name="end_time" value=""/><!-- 活动结束时间 -->
            <input type="hidden" name="activity_title" value=""/><!-- 活动标题 -->
            <input type="hidden" name="prom_detail" value=""/><!-- 促销活动的促销类型 -->
            <input type="hidden" name="activity_is_on" value=""/><!-- 活动是否正在进行中 -->
            <input type="hidden" name="item_id" value=""/><!-- 商品规格id -->
            <input type="hidden" name="exchange_integral" value="0"/><!-- 积分 -->
            <input type="hidden" name="point_rate" value="1"/><!-- 积分兑换比 -->
            <input type="hidden" name="is_virtual" value="1"/><!-- 是否是虚拟商品 -->
            <input type="hidden" name="store_name" value="数集小镇"/>
            <input type="hidden" name="goods_name" value="航班动态（API）"/>
            <div class="detail-ggsl">
                <div class="goods-title">
                    <span class="title"><?php echo $data['data_name']?></span>
                </div>
                <p class="goods-introduce"><?php echo $data['data_desc']?></p>
                <p class="goods-tag">标签：
                	<?php foreach($data['label'] as $item):?>
                		<span><?php echo $item?></span>
                	<?php endforeach;?>
                </p>
                <div style="background: #f8f8f8">
                    <div class="shop-price-cou">
                        <div class="shop-price-le">
                            <ul>
                                <li class="jaj"><span id="goods_price_title">价格：</span></li>
                                <li>
									<span class="bigpri_jj" id="goods_price"><em>￥</em>
										<?php echo $data['data_price']?>
									</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="standard p">
                        <ul>
                            <li class="jaj"><span>规格：</span></li>
                        </ul>
                    </div>
                    <div class="standard goods-standard">
                        <ul>
                            <li class="re"><span>1</span>份/<i class="c_price"><?php echo $data['data_price']?></i>元</li>
                        </ul>
                    </div>
                </div>
                <div class="standard p" style="margin-top:50px;">
                    <ul>
                        <li class="jaj"><span>数量：</span></li>
                        <li class="lawir">
                            <div class="minus-plus">
                                <a class="mins" href="javascript:void(0);" onclick="altergoodsnum(-1)">-</a>
                                <input class="buyNum" id="number" type="text" name="goods_num" value="1"
                                       onblur="altergoodsnum(0)" max=""/>
                                <a class="add" href="javascript:void(0);" onclick="altergoodsnum(1)">+</a>
                            </div>
                        </li>
                    </ul>
                </div>
                <div class="standard p fr " style="margin:-37px 220px 0px 0px;">
                    <input type="hidden" name="goods_id" value="8"/>
                    <a id="join_cart_now" class="paybybill" href="" target="_blank" onclick="this.href='<?=base_url()?>index.php/home/gopay/index?param=<?php echo $data['id']?>&number='+$('#number').val();">立即购买</a>
                </div>
            </div>
        </form>
        <div class="detail-ry p">
            <div class="cooperation">提供商名称（数集小镇）</div>
            <div class="store-contact">
                <div class="contact-l">
                    联系服务商
                </div>
                <div class="contact-r">
                    <a href="tencent://message/?uin=&Site=www.zhuashou.net&Menu=yes">
                        <i><img src="Picture/msg.png" alt=""></i>
                        8888888888
                    </a>
                    <a href="javascript:;">
                        <i><img src="Picture/phone.png" alt=""></i>
                        010-88888888
                    </a>
                </div>
                <div class="contact-time">
                    <p>在线时间</p>
                    工作日：9：00-18：00
                </div>
            </div>
            <div class="canvas">
                <ul class="fl data_c">
                    <!--数据满意度-->
                    <li>
                        <canvas id="d_canvas" class="d_canvas" width="100" height="100"></canvas>
                        <script>
                            //数据满意度
                            var d_canvas = document.getElementById('d_canvas'),  //获取canvas元素
                                d_context = d_canvas.getContext('2d'),  //获取画图环境，指明为2d
                                d_centerX = d_canvas.width / 2,   //Canvas中心点x轴坐标
                                d_centerY = d_canvas.height / 2,  //Canvas中心点y轴坐标
                                d_rad = Math.PI * 2 / 100, //将360度分成100份，那么每一份就是rad度
                                // d_speed = 0; //加载的百分比
                                d_speed = 99

                            //绘制黄色内圈
                            function d_yellowCircle(m) {
                                d_context.save();
                                d_context.strokeStyle = "#FFC76E"; //设置描边样式
                                d_context.lineWidth = 10; //设置线宽
                                d_context.beginPath(); //路径开始
                                d_context.arc(d_centerX, d_centerY, 40, -Math.PI / 2, -Math.PI / 2 - m * d_rad, true); //用于绘制圆弧context.arc(x坐标，y坐标，半径，起始角度，终止角度，顺时针/逆时针)
                                d_context.stroke(); //绘制
                                d_context.closePath(); //路径结束
                                d_context.restore();
                            }

                            //绘制文字
                            function d_word() {
                                d_context.save();
                                d_context.beginPath();
                                d_context.font = '24px Arial';
                                d_context.fillStyle = '#FFC76E';
                                d_context.fillText(d_speed + '%', 24, 60);
                                d_context.closePath();
                                d_context.restore();
                            }

                            //绘制白色外圈
                            function d_whiteCircle() {
                                d_context.save();
                                d_context.beginPath();
                                d_context.strokeStyle = "#F8F8F8";
                                d_context.lineWidth = 10;
                                d_context.arc(d_centerX, d_centerY, 40, 0, Math.PI * 2, true);
                                d_context.stroke();
                                d_context.closePath();
                                d_context.restore();
                            }

                            (function d_drawFrame() {
                                window.requestAnimationFrame(d_drawFrame, d_canvas);
                                d_context.clearRect(0, 0, d_canvas.width, d_canvas.height);
                                d_whiteCircle();
                                d_word();
                                d_yellowCircle(d_speed);
                            }());
                        </script>
                    </li>
                    <li>数据满意度</li>
                </ul>
                <!--服务满意度-->
                <ul class="fr sever_c">
                    <li>
                        <canvas id="s_canvas" class="s_canvas" width="100" height="100"></canvas>
                        <script>
                            //服务满意度
                            var s_canvas = document.getElementById('s_canvas'),  //获取canvas元素
                                s_context = s_canvas.getContext('2d'),  //获取画图环境，指明为2d
                                s_centerX = s_canvas.width / 2,   //Canvas中心点x轴坐标
                                s_centerY = s_canvas.height / 2,  //Canvas中心点y轴坐标
                                s_rad = Math.PI * 2 / 100, //将360度分成100份，那么每一份就是rad度
                                // s_speed = 0; //加载的百分比
                                s_speed = 99

                            //绘制黄色内圈
                            function s_yellowCircle(n) {
                                s_context.save();
                                s_context.strokeStyle = "#FFC76E"; //设置描边样式
                                s_context.lineWidth = 10; //设置线宽
                                s_context.beginPath(); //路径开始
                                s_context.arc(s_centerX, s_centerY, 40, -Math.PI / 2, -Math.PI / 2 - n * s_rad, true); //用于绘制圆弧context.arc(x坐标，y坐标，半径，起始角度，终止角度，顺时针/逆时针)
                                s_context.stroke(); //绘制
                                s_context.closePath(); //路径结束
                                s_context.restore();
                            }

                            //绘制文字
                            function s_word() {
                                s_context.save();
                                s_context.beginPath();
                                s_context.font = '24px Arial';
                                s_context.fillStyle = '#FFC76E';
                                s_context.fillText(s_speed + '%', 24, 60);
                                s_context.closePath();
                                s_context.restore();
                            }

                            //绘制白色外圈
                            function s_whiteCircle() {
                                s_context.save();
                                s_context.beginPath();
                                s_context.strokeStyle = "#F8F8F8";
                                s_context.lineWidth = 10;
                                s_context.arc(s_centerX, s_centerY, 40, 0, Math.PI * 2, true);
                                s_context.stroke();
                                s_context.closePath();
                                s_context.restore();
                            }

                            (function s_drawFrame() {
                                window.requestAnimationFrame(s_drawFrame, s_canvas);
                                s_context.clearRect(0, 0, s_canvas.width, s_canvas.height);
                                s_whiteCircle();
                                s_word();
                                s_yellowCircle(s_speed);
                            }());
                        </script>
                    <li>服务满意度</li>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<div class="detail-main p">
    <div class="w1224">
        <div class="deta-ri-ma">
            <div class="type_more">
                <div class="type-top">
                    <p>搭配数据</p>
                </div>
                <div class="tjhot-shoplist type-bot">
                                            <div class="alone-shop">
                            <a href="/packetinfo-41"><img
                                    src="Picture/goods_thumb_41_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-41.html">招聘信息查询（API）</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>399.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-40"><img
                                    src="Picture/goods_thumb_40_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-40.html">旅客消费能力评估(API)</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>699.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-26"><img
                                    src="Picture/goods_thumb_26_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-26.html">国际新闻(平台外交易 api json )</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>11.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-27"><img
                                    src="Picture/goods_thumb_27_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-27.html">票房信息(免费 api json )</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>15.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-28"><img
                                    src="Picture/goods_thumb_28_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-28.html">电视节目表(免费 api json )</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>50.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-29"><img
                                    src="Picture/goods_thumb_29_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-29.html">影视数据——影片/评论/影人/票房等(平台外交易 api j...</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>10.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-31"><img
                                    src="Picture/goods_thumb_31_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-31.html">移动游戏分析(免费 )</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>3.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-32"><img
                                    src="Picture/goods_thumb_32_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-32.html">  游戏运营支撑平台(平台外交易 )</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>12.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-34"><img
                                    src="Picture/goods_thumb_34_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-34.html">移动游戏统计分析——玩家分析/付费分析/游戏设计分析(免费 ...</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>22.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-36"><img
                                    src="Picture/goods_thumb_36_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-36.html">音乐api：曲库、歌手、专辑榜单、铃声、用户信息(免费 ap...</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>3.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-37"><img
                                    src="Picture/goods_thumb_37_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-37.html">一听音乐 —— 一听音乐网（www.1ting.com）(免...</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>14.00</span></p>
                        </div>
                                            <div class="alone-shop">
                            <a href="/packetinfo-38"><img
                                    src="Picture/goods_thumb_38_206_206.jpeg" style="display: inline;"></a>
                            <p class="line-two-hidd"><a
                                    href="/reportinfo-38.html">音乐搜索 —— 搜索歌曲和查看歌曲信息(平台外交易 api ...</a>
                            </p>
                            <p class="price-tag"><span class="li_xfo">￥</span><span>10.00</span></p>
                        </div>
                                    </div>
            </div>
        </div>
        <!--API数据使用-->
        <div class="deta-le-ma">
            <div class="introduceshop">
                <div class="datail-nav-top">
                    <ul>
                        <li class="red"><a href="javascript:void(0);">数据样例</a></li>
                        <li><a href="javascript:void(0);">字段说明</a></li>
                        <li><a href="javascript:void(0);">其它相关</a></li>
                    </ul>
                </div>
                <div class="shop-describe shop-con-describe p">
                     <div class="code">
                        <div><i class="i_mark"></i><span>数据样例</span></div>
                        <div class="top_mark"></div>
                        <table border="0" cellpadding="0" cellspacing="0" align="center">
                            <tr class="bs">
                            	<?php foreach($data['param_name'] as $item):?>
                                <th><?php echo $item?></th>
                                <?php endforeach;?>
                            </tr>
                            <?php foreach($data['temple'] as $item):?>
                            <tr>
                            	<?php foreach($item as $it):?>
                                <td><?php echo $it?></td>
                                <?php endforeach;?>
                            </tr>
                        	<?php endforeach;?>
                        </table>                  
                    </div>                    
                </div>
                <div class="shop-describe shop-con-describe p" style="display: none;">
                    <div class="code">
                        <div><i class="i_mark"></i><span>文件字段说明</span></div>
                        <div class="top_mark"></div>
                        <table border="0" cellpadding="0" cellspacing="0" align="center">
                            <tr class="bs">
                                <th>参数名</th>
                                <th>类型</th>                          
                                <th>示例值</th>
                                <th>描述</th>
                            </tr>
                            <?php foreach($data['field_name'] as $item):?>
                            <tr>
                            	<?php foreach($item as $it):?>
                                <td><?php echo $it;?></td>
                                <?php endforeach;?>
                            </tr> 
                        	<?php endforeach;?>
                        </table>
                        <!-- <p></p> -->
                    </div>                   
                </div>
                <div class="shop-describe shop-con-describe p" style="display: none;">
                    <div class="code">
                        <div><i class="i_mark"></i><span>代码样例</span></div>
                        <!-- <p class="Fexample"></p> -->
                        <div class="Fexample">
                            {<br>
                            "hasNext": true,<br>
                            "retcode": "000000",<br>
                            "appCode": "qihoo",<br>
                            "dataType": "news",<br>
                            "pageToken": "2",<br>
                            "data": [<br>
                            {<br>
                            "posterId": null,<br>
                            "content": "最新的剧情中,陆晨曦(",<br>
                            "posterScreenName": "腾讯",<br>
                            "tags": null,<br>
                            "url": "http:\/\/ent.qq.com\/a\/20170508\/023354.htm",<br>
                            "publishDateStr": "2017-05-08T03:46:00",<br>
                            "title": "白百何陷医患风波 《外科》靳东职业生涯遇危机",<br>
                            "publishDate": 1494215160,<br>
                            "commentCount": null,<br>
                            "imageUrls": null,<br>
                            "id": "c028fc8126658124bc8f21a13650d51b"<br>
                            }<br>
                            ]<br>
                            }<br>
                        </div>
                    </div>
                    <div class="code">
                        <div><i class="i_mark"></i><span>错误码参照</span></div>
                        <!-- <p></p> -->
                        <div class="top_mark"></div>
                        <table border="0" cellpadding="0" cellspacing="0" align="center">
                            <tr class="bs">
                                <th class="tal">错误码</th>
                                <th class="ewt tal">错误码返回</th>
                                <th class="ewt">错误码返回说明</th>
                            </tr>
                            <tr>
                                <td class="tal">100101</td>
                                <td class="tal">Missing apikey</td>
                                <td>缺少请求apikey，登录即可获取</td>
                            </tr>
                        </table>
                    </div>
                    <div class="code">
                        <div><i class="i_mark"></i><span>错误码格式</span></div>
                        <!-- <p></p> -->
                        <div class="top_mark"></div>
                        <table border="0" cellpadding="0" cellspacing="0" align="center">
                            <tr class="bs">
                                <th class="tal">错误码</th>
                                <th class="ewt tal">错误码返回</th>
                                <th class="ewt">错误码返回说明</th>
                            </tr>
                            <tr>
                                <td class="tal">100101</td>
                                <td class="tal">Missing apikey</td>
                                <td>缺少请求apikey，登录即可获取</td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--测试工具弹窗-->
<div class="tt_tc">
    <span class="dl_load"></span>
    <div class="get_data">
        <p><span class="get_file fl">获取APPKEY</span><span class="closeX fr"></span></p>
        <div class="appkey">
            7389nfh87ew9fndfiu9eoicsc0wcwe93
        </div>
        <ul class="appkey_remind">
            <li>1.以上是您在抓手数据网调用API数据所需的APPKEY，此AIPKEY可调用抓手平台<br>&nbsp;&nbsp;&nbsp;所有即用服务。
            </li>
            <li>2.您可通过数据测试以及我的订单页面查看您的APPKEY，为了数据安全调用，请<br>&nbsp;&nbsp;&nbsp;不要将此APPKEY复制给他人使用。
            </li>
        </ul>
        <a href="/Home-Goods-testSDK.html" target="_blank" class="copy_use">复制并调用</a>
    </div>
    <div class="site_rz h360">
        <p><span class="site_title fl">抓手数据网认证</span><span class="closeX fr"></span></p>
        <div class="site_Rinfo">
            用户您好！<br>
            为了给您提供更优质的售后服务，保障您在平台获得更多权益，需要您
            登录个人中心完成用户认证操作。完成用户认证后，您可在平台顺利购
            买数据。<br>
            <br>
            未进行认证操作的用户或将影响您的购物体验，望各位知悉。
        </div>
        <div style="text-align: center">
            <a href="javascript:;" class="site_btn1">暂不认证</a><a href="/Home-Authentication-ent_step1.html" class="site_btn2">企业认证</a><a href="/Home-Authentication-per_step1.html" class="site_btn3">个人认证</a>
        </div>
    </div>
</div>
<!--footer-s-->
<div class="goContact">
    <img src="Picture/contact.png" alt="客服">
</div>
<div class="contact_type">
    <div class="right-contact-us">
        <span class="phone">010-65916788</span>
    </div>
</div>
<div class="goTop">
    <img src="Picture/gotop.png" alt="返回顶部">
</div>
<script>
    var min_height = $(window).height();
    $(window).scroll(function () {
        var s = $(window).scrollTop();
        if (s > min_height) {
            $(".goTop").show();
        } else {
            $(".goTop").hide();
        }
        ;
    });
    $(".goTop").mouseenter(function () {
        $(this).find("img").attr("src", "/template/pc/rainbow/static/images/goTop_w.png");
        $(".goTop").click(function () {
            $("html,body").animate({scrollTop: 0}, 500);
        });
        $(".goTop").mouseleave(function () {
            $(this).find("img").attr("src", "/template/pc/rainbow/static/images/goTop.png");
        });
    });
    $(".goContact").mouseenter(function () {
        $(".contact_type").animate({width: "135px"}, 100);
        $(this).find("img").attr("src", "/template/pc/rainbow/static/images/contact_w.png");
        $(".goContact").mouseleave(function () {
            $(".contact_type").animate({width: "0px"}, 100);
            $(this).find("img").attr("src", "/template/pc/rainbow/static/images/contact.png");
        });
    });
</script>

<script>
    var footerT = min_height - 346;
    var bodyH = $("body").height();
    if (bodyH <= min_height) {
        $(".footer").css({
            position: 'absolute',
            top: footerT + 'px',
            bottom: 0,
            left: 0,
            right: 0
        });
    }
</script>

<!--footer-e-->
<script src="Scripts/lazyload.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="Scripts/headerfooter.js"></script>
<script type="text/javascript">
    function no_rz() {
        if (getCookie('user_id') == '') {
            pop_login();
            return false;
        }
        //测试工具
        //获取appkey
        $(".test_tool").click(function () {
            $(".get_data").show();
            $(".dl_load").show();
        });
        $(".closeX").click(function () {
            $(".get_data").hide();
            $(".dl_load").hide();
            $(".site_rz").hide();
        });
        $(".paybybill").click(function () {
            $(".site_rz").show();
            $(".dl_load").show();
        });
        $(".site_btn1").click(function () {
            $(".site_rz").hide();
            $(".dl_load").hide();
        });
    }

    var commentType = 1;// 默认评论类型
    var spec_goods_price = []    ;//规格库存价格

    $(document).ready(function () {
        initSpec();
        initGoodsPrice();
    });
    $(".goods-standard li").click(function () {
        $(".goods-standard li").removeClass("re");
        $(this).addClass("re");
        $("#number").val($(this).find("span").text());
    });

    //有规格id的时候，解析规格id选中规格
    function initSpec() {
        var item_id = $("input[name='item_id']").val();
        $.each(spec_goods_price, function (i, o) {
            if (o.item_id == item_id) {
                var spec_key_arr = o.key.split("_");
                $.each(spec_key_arr, function (index, item) {
                    var spec_radio = $("#goods_spec_" + item);
                    var goods_spec_a = $("#goods_spec_a_" + item);
                    spec_radio.attr("checked", "checked");
                    goods_spec_a.addClass('red');
                })
            }
        })
        if (item_id > 0 && !$.isEmptyObject(spec_goods_price)) {
            var item_arr = [];
            $.each(spec_goods_price, function (i, o) {
                item_arr.push(o.item_id);
            })
            //规格id不存在商品里
            if ($.inArray(parseInt(item_id), item_arr) < 0) {
                initFirstSpec();
            } else {
                $.each(spec_goods_price, function (i, o) {
                    if (o.item_id == item_id) {
                        var spec_key_arr = o.key.split("_");
                        $.each(spec_key_arr, function (index, item) {
                            var spec_radio = $("#goods_spec_" + item);
                            var goods_spec_a = $("#goods_spec_a_" + item);
                            spec_radio.attr("checked", "checked");
                            goods_spec_a.addClass('red');
                        })
                    }
                })
            }
        } else {
            initFirstSpec();
        }
    }

    //默认让每种规格第一个选中
    function initFirstSpec() {
        $('.spec_goods_price_div').each(function (i, o) {
            var firstSpecRadio = $(this).find("input[type='radio']").eq(0);
            firstSpecRadio.attr('checked', 'checked').prop('checked', 'checked');
            firstSpecRadio.parent().find('a').eq(0).addClass('red');
        })
    }

    /**
     * 切换规格
     */
    function select_filter(obj) {
        $(obj).addClass('red').siblings('a').removeClass('red');
        $(obj).siblings('input').removeAttr('checked');
        $(obj).prev('input').attr('checked', 'checked').prop('checked', 'checked');
        // 更新商品价格
        initGoodsPrice();
    }

    function virtual_buy() {
        var store_count = $("input[name='store_count']").attr('value');// 商品原始库存
        var buyNum = parseInt($("input[name='goods_num']").val());
        $('#buy_goods_form').submit();

    }

    $(function () {
        ajaxComment(1, 1)
        $("#area").click(function (e) {
            SelCity(this, e);
        });

        $('.colo a').click(function () {
            $(this).addClass('red').siblings('a').removeClass('red');
        })
        // 好评差评 切换
        $('.cte-deta ul li').click(function () {
            $(this).addClass('red').siblings().removeClass('red');
            commentType = $(this).data('t');// 评价类型   好评 中评  差评
            ajaxComment(commentType, 1);
        })

        $('.datail-nav-top ul li').click(function () {
            $(this).addClass('red').siblings().removeClass('red');
            var er = $('.datail-nav-top ul li').index(this);
            $('.shop-con-describe').eq(er).show().siblings('.shop-con-describe').hide();
        })
    });

    /**
     * 加减数量
     * n 点击一次要改变多少
     * maxnum 允许的最大数量(库存)
     * number ，input的id
     */
    function altergoodsnum(n) {
        var num = parseInt($('#number').val());
        var maxnum = parseInt($('#number').attr('max'));
        if (maxnum > 9999) {
            maxnum = 9999;
        }
        num += n;
        num <= 0 ? num = 1 : num;
        if (num >= maxnum) {
            $(this).addClass('no-mins');
            num = maxnum;
        }
        $('#store_count').text(maxnum - num); //更新库存数量
        $('#number').val(num)
    }

    //初始化商品价格库存
    function initGoodsPrice() {
        var goods_id = $('input[name="goods_id"]').val();
        if (!$.isEmptyObject(spec_goods_price)) {
            var goods_spec_arr = [];
            $("input[name^='goods_spec']").each(function () {
                if ($(this).attr('checked') == 'checked') {
                    goods_spec_arr.push($(this).val());
                }
            });
            var spec_key = goods_spec_arr.sort(sortNumber).join('_');  //排序后组合成 key
            var item_id = spec_goods_price[spec_key]['item_id'];
            $('input[name=item_id]').val(item_id);
        }
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {goods_id: goods_id, item_id: item_id},
            url: "/Home-Goods-activity.html",
            success: function (data) {
                if (data.status == 1) {
                    $('input[name="shop_price"]').attr('value', data.result.goods.shop_price);//商品价格
                    $('input[name="store_count"]').attr('value', data.result.goods.store_count);//商品库存
                    $('input[name="market_price"]').attr('value', data.result.goods.market_price);//商品原价
                    goods_activity_theme();
                }
            }
        });
    }

    //商品价格库存显示
    function goods_activity_theme() {
        var goods_prom_type = $('input[name="goods_prom_type"]').attr('value');
        var activity_is_on = $('input[name="activity_is_on"]').attr('value');
        if (activity_is_on == 0) {
            setNormalGoodsPrice();
        } else {
            if (goods_prom_type == 0 || goods_prom_type == 6) {
                //普通商品
                setNormalGoodsPrice();
            }
        }
        var buy_num = $('#number').val();//购买数
        var store = $('#spec_store_count').html();//实际库存数量
        if (store <= 0) {
            joinCart(false);
        } else {
        }
        if (store <= 0) {
            $('.buyNum').val(store);
        } else {
            $('.buyNum').val(1);
        }
    }

    //普通商品库存和价格
    function setNormalGoodsPrice() {
        var goods_price = $("input[name='shop_price']").attr('value');// 商品本店价
        var market_price = $("input[name='market_price']").attr('value');// 商品市场价
        var store_count = $("input[name='store_count']").attr('value');// 商品库存
        var exchange_integral = $("input[name='exchange_integral']").attr('value');// 兑换积分
        var point_rate = $("input[name='point_rate']").attr('value');// 积分金额比
        // 如果有属性选择项
        if (!$.isEmptyObject(spec_goods_price)) {
            var goods_spec_arr = [];
            $("input[name^='goods_spec']").each(function () {
                if ($(this).attr('checked') == 'checked') {
                    goods_spec_arr.push($(this).val());
                }
            });
            var spec_key = goods_spec_arr.sort(sortNumber).join('_');  //排序后组合成 key
            goods_price = spec_goods_price[spec_key]['price']; // 找到对应规格的价格
            store_count = spec_goods_price[spec_key]['store_count']; // 找到对应规格的库存
        }
        $('#market_price_title').empty().html('市场价：');
        $('#market_price').empty().html(market_price);
        $("#goods_price").html("<em>￥</em>" + goods_price); //变动价格显示
        var integral = round(goods_price - (exchange_integral / point_rate), 2);
        $('#spec_store_count').html(store_count);
        $('.presale-time').hide();
        $('#number').attr('max', store_count);
    }

    //排序
    function sortNumber(a, b) {
        return a - b;
    }

    /**
     * 立即购买
     */
    function buy_now() {
        if (getCookie('user_id') == '') {
            pop_login();
            return false;
        }
        var store_count = $("input[name='store_count']").attr('value');// 商品原始库存
        var buyNum = parseInt($("input[name='goods_num']").val());
        var buyNum = $("input[name='goods_num']").val();
        $('#buy_goods_form').submit();
    }

    //收藏商品
    $('#collectLink').click(function () {
        if (getCookie('user_id') == '') {
            pop_login();
        } else {
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {goods_id: $('input[name="goods_id"]').val()},
                url: "/Home-Goods-collect_goods.html",
                success: function (res) {
                    if (res.status == 1) {
                        layer.msg('成功添加至收藏夹', {icon: 1});
                        $('.collect-ico').css('background', 'url(/template/pc/rainbow/static/images/collected.png) 0% 0% / 100% no-repeat');
                    } else {
                        layer.msg(res.msg, {icon: 3});
                    }
                }
            });
        }
    });

    function pop_login() {
        layer.open({
            type: 2,
            title: '登录抓手数据网',
            skin: 'layui-layer-rim',
            shadeClose: true,
            shade: 0.5,
            area: ['490px', '460px'],
            content: "/Home-User-pop_login.html",
        });
    }

    //用ajax分页显示评论
    function ajaxComment(commentType, page) {
        $.ajax({
            type: "GET",
            url: "/index.php?m=Home&c=goods&a=ajaxComment&goods_id=8&commentType=" + commentType + "&p=" + page,//+tab,
            success: function (data) {
                $("#ajax_comment_return").html('');
                $("#ajax_comment_return").append(data);
            }
        });
    }

    /****************************************   评论js  ****************************************/
    // 点击分页触发的事件
    $(document).on("click", "#ajax_comment_return .pagination  a", function () {
        ajaxComment(commentType, $(this).data('p'));
    });

    /**
     * 点赞ajax
     * dyr
     * @param obj
     */
    function zan(obj) {
        var comment_id = $(obj).attr('data-comment-id');
        var zan_num = parseInt($("#span_zan_" + comment_id).text());
        $.ajax({
            type: "POST",
            data: {comment_id: comment_id},
            dataType: 'json',
            url: "/index.php?m=Home&c=Order&a=ajaxZan",//
            success: function (res) {
                if (res.success) {
                    $("#span_zan_" + comment_id).text(zan_num + 1);
                } else {
                    layer.msg('只能点赞一次哟~', {icon: 2});
                }
            },
            error: function (res) {
                if (res.status == "200") { // 兼容调试时301/302重定向导致触发error的问题
                    layer.msg("请先登录!", {icon: 2});
                    return;
                }
                layer.msg("请求失败!", {icon: 2});
                return;
            }
        });
    }

    //字数限制
    $(function () {
        $('.c-cen').click(function () {
            $(this).parents('.deta-descri').siblings('.reply-textarea').toggle();
        })
        $(document).on('click', '.J-reply-trigger', function () {
            $(this).siblings('.reply-textarea').toggle();
        })
        $('.reply-input').keyup(function () {
            var nums = 120;
            var len = $(this).val().length;
            if (len > nums) {
                $(this).val($(this).val().substring(0, nums));
                layer.msg("超过字数限制！", {icon: 2});
            }
            var num = nums - len;
            var su = $(this).siblings().find('.txt-countdown em');
            su.text(num);
        })

        $(document).on('click', '.operate-box .reply-submit', function () {
            var content = $(this).parents('.inner').find('.reply-input').val();
            var comment_id = $(this).parents('.inner').find('.reply-input').attr('data-id').substr(10);
            var comment_name = $(this).parents('.comment-operate').siblings('.reply-infor').find('.main .user-name').text();
            var reply_id = $(this).attr('data-id');
            submit_reply(comment_id, content, comment_name, reply_id);
            $(this).parents('.reply-textarea').hide();
        });
    })

    /**
     * 回复
     * @param comment_id
     * @param content
     * @param to_name
     * @param reply_id
     */
    function submit_reply(comment_id, content, to_name, reply_id) {
        var goods_id = $('input[name="goods_id"]').val();
        if (getCookie('user_id') == '') {
            pop_login();
        } else {
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {
                    comment_id: comment_id,
                    content: content,
                    to_name: to_name,
                    reply_id: reply_id,
                    goods_id: goods_id
                },
                url: "/Home-Order-reply_add.html",
                success: function (res) {
                    if (res.status == 1) {
                        layer.msg(res.msg, {icon: 1});
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                },
                error: function (res) {
                    if (res.status == "200") { // 兼容调试时301/302重定向导致触发error的问题
                        layer.msg("请先登录!", {icon: 2});
                        return;
                    }
                    layer.msg("请求失败!", {icon: 2});
                }
            });
        }
    }

    /****************************************   评论js  ****************************************/
</script>
<!--商品咨询JS-->
<script>
    // 普通 图形验证码
    function verify() {
        $('#verify_code').attr('src', '/index.php?m=Home&c=User&a=verify&type=consult&r=' + Math.random());
    }

    var consult = $('#consult-h');
    consult.find('.consult-item').eq(0).addClass('consult-ac');
    consult.find('.consult-menus>a').click(function () {
        $(this).addClass('consult-ac').siblings().removeClass('consult-ac');
        consult.find('.consult-item').eq($(this).index())
            .addClass('consult-ac').siblings().removeClass('consult-ac');
        $('.check-consult-tpye').find('a').eq($(this).index())
    });
    $(document).ready(function () {
        verify();
    });
    $(document).on('click', '.pagination  a', function () {
        var page = $(this).data('p');
        var type = $('#type').val();
        getconsult(type, page)
    });

    /**
     * 获取商品咨询
     * @param type  //咨询类型
     * @param page  //分页
     */
    function getconsult(type, page) {
        var goods_id = $('input[name="goods_id"]').val();
        $('#type').val(type);
        var url = "/index.php?m=Home&c=Goods&a=ajax_consult";
        $.ajax({
            type: "Post",
            url: url,
            data: {goods_id: goods_id, consult_type: type, p: page},
            dataType: "html",
            success: function (data) {
                $('#consult_content').html('').append(data);
            }
        });
    }
</script>
</body>
</html>